﻿using MediatR;
using Yuekao.API.Read.Command;
using Yuekao.Domain.API;
using Yuekao.Domain.BaseReposi;
using Yuekao.Domain.Entitys;

namespace Yuekao.API.Read.CommandHandler
{
    public class UserShowCommandHandler : IRequestHandler<UserShowCommand, APIResult<List<UserModel>>>
    {
        private readonly IBaseRepository<UserModel> _repository;
        public UserShowCommandHandler(IBaseRepository<UserModel> repository)
        {
            _repository = repository;
        }
        public Task<APIResult<List<UserModel>>> Handle(UserShowCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<UserModel>> result = new APIResult<List<UserModel>>();
            result.Code = APIEnum.Success;
            result.Message = "用户下拉框显示成功";
            var list = _repository.GetAll();
            result.Data = list.ToList();
            return Task.FromResult(result);
        }
    }
}
